Fix ordering in optional altitude test in KML reader
authorRobert Lipe <robertlipe@gpsbabel.org>
Mon, 9 Dec 2019 06:55:31 +0000 (00:55 -0600)
committerRobert Lipe <robertlipe@gpsbabel.org>
Mon, 9 Dec 2019 06:55:31 +0000 (00:55 -0600)
kml.cc

diff --git a/kml.cc b/kml.cc
index b3f830e5c98226cb298af4f87a2cfa0f2d7b6e7d..f9d06f6644472d0922997b2b1f006ce89ae78d2f 100644 (file)
--- a/kml.cc
+++ b/kml.cc
@@ -417,11 +417,13 @@ void trk_coord(xg_string args, const QXmlStreamAttributes*)
     QStringList coords = vec.split(',');
     auto csize = coords.size();
     auto trkpt = new Waypoint;
-    if (csize >= 2) {
+
+    if (csize == 3) {
+      trkpt->altitude = coords[2].toDouble();
+    }
+    if (csize == 2 || csize == 3) {
       trkpt->latitude = coords[1].toDouble();
       trkpt->longitude = coords[0].toDouble();
-    } else if (csize >= 3) {
-      trkpt->altitude = coords[2].toDouble();
     } else {
       Warning() << MYNAME << ": malformed coordinates " << vec;
     }